package test;

/**
 * @Author: Wyndem
 * @Description: 温度板，用来监控当前温度
 * @Date: Created in  2019-01-20 20:05
 * @Modified By:
 */
public class Temperature  implements Observers{


    //包含一个天气站的主题
    private WeatherStation subject;


    public Temperature(Subject subject) {
        if (subject instanceof  WeatherStation){
            this.subject= (WeatherStation) subject;
        }

    }

     /**
      * @title: 更新
      * @description:  当温度发送变化会更新
      * @author:  Wyndem
      * @date:  2019/1/20  20:07
      **/
    @Override
    public void updata() {
        //主动拉取需要的数据
        Double temperature = subject.getTemperature();
        String msg = new StringBuilder()
                                    .append("当前的温度为：")
                                    .append(temperature.toString()).toString();
        System.out.println(msg);
    }
}
